package com.xiejun.service.impl;


import com.spring.annotation.Autowired;
import com.spring.annotation.Component;
import com.spring.annotation.Scope;
import com.spring.bean.BeanNameAware;
import com.spring.bean.InitializingBean;
import com.xiejun.service.IUserService;
import com.xiejun.service.OrderService;

@Component("userService")
@Scope("prototype")
public class UserServiceImpl implements BeanNameAware, InitializingBean, IUserService {

    // 使用接口类型而不是具体实现类
    @Autowired
    private OrderService orderService;

    private String name;

    @Override
    public void setBeanName(String name) {
        this.name = name;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("初始化");
    }

    @Override
    public void test() {
        System.out.println(orderService);
        System.out.println(name);
    }
}